#include "seq_stack.h"

int main(int argc, const char *argv[]){
    stack_t *my_stack = NULL;
    create_stack(&my_stack);
    printf("mny_stack = %p\n", my_stack); // 非NULL

    // 测试入栈
    push_stack(my_stack, 10);
    push_stack(my_stack, 20);
    push_stack(my_stack, 30);
    print_stack(my_stack); // 10 20 30

    // 测试出栈
    int value = 0;
    int ret = 0;
    ret = pop_stack(my_stack, &value);
    printf("ret = %d  value = %d\n", ret, value); // 0  30
    ret = pop_stack(my_stack, &value);
    printf("ret = %d  value = %d\n", ret, value); // 0  20

    // 测试入栈
    push_stack(my_stack, 40);
    push_stack(my_stack, 50);
    push_stack(my_stack, 60);
    push_stack(my_stack, 70);
    push_stack(my_stack, 80); // 满 入栈失败
    print_stack(my_stack); // 10 40 50 60 70

    // 测试出栈
    ret = pop_stack(my_stack, &value);
    printf("ret = %d  value = %d\n", ret, value); // 0  70
    ret = pop_stack(my_stack, &value);
    printf("ret = %d  value = %d\n", ret, value); // 0  60
    ret = pop_stack(my_stack, &value);
    printf("ret = %d  value = %d\n", ret, value); // 0  50
    ret = pop_stack(my_stack, &value);
    printf("ret = %d  value = %d\n", ret, value); // 0  40
    ret = pop_stack(my_stack, &value);
    printf("ret = %d  value = %d\n", ret, value); // 0  10
    ret = pop_stack(my_stack, &value); // 栈空 出站失败
    printf("ret = %d  value = %d\n", ret, value); // -1

    // 测试清空
    push_stack(my_stack, 100);
    push_stack(my_stack, 200);
    push_stack(my_stack, 300);
    print_stack(my_stack); // 100 200 300
    clean_stack(my_stack);
    print_stack(my_stack); // 没有元素了

    // 测试销毁
    destroy_stack(&my_stack);
    printf("mny_stack = %p\n", my_stack); // NULL

    return 0;
}